package com.qixin.modules.ea.controller;

import java.io.IOException;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSONObject;
import com.qixin.modules.ea.entity.*;
import com.qixin.modules.ea.mapper.EaTravelMapper;
import com.qixin.modules.ea.vo.EaTravelPrintVo;
import com.qixin.modules.eaApplication.entity.EaBusinessApply;
import com.qixin.modules.eaApplication.entity.EaEntertainApply;
import com.qixin.modules.eaApplication.service.IEaBusinessApplyService;
import com.qixin.modules.eaBasic.entity.EaTask;
import com.qixin.modules.rzInvoice.entity.EaBill;
import com.qixin.modules.rzInvoice.service.IEaHotelbookspersondService;
import com.qixin.modules.rzInvoice.service.impl.EaBillServiceImpl;
import com.qixin.modules.rzInvoice.vo.EaCheckInPersonVo;
import com.qixin.utils.PreciseCompute;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.util.ConvertUpMoneyUtil;
import org.jeecg.common.util.FillRuleUtil;
import org.jeecg.modules.activiti.entity.ActZTask;
import org.jeecg.modules.activiti.mapper.ActZTaskMapper;
import org.jeecg.modules.activity.service.ActivityCommonService;
import org.jeecg.modules.nc.entity.NcPersonnel;
import org.jeecg.modules.nc.service.INcPersonnelService;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.jeecg.common.system.vo.LoginUser;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.util.oConvertUtils;
import com.qixin.modules.ea.vo.EaTravelPage;
import com.qixin.modules.ea.service.IEaTravelService;
import com.qixin.modules.ea.service.IEaBookDetailService;
import com.qixin.modules.ea.service.IEaApplyDetailService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.aspect.annotation.AutoLog;

 /**
 * @Description: ea_travel
 * @Author: qixin-boot
 * @Date:   2022-01-21
 * @Version: V1.0
 */
@Api(tags="差旅费报销单")
@RestController
@RequestMapping("/ea/eaTravel")
@Slf4j
public class EaTravelController {
	@Autowired
	private IEaTravelService eaTravelService;
	@Autowired
	private IEaBookDetailService eaBookDetailService;
	@Autowired
	private IEaApplyDetailService eaApplyDetailService;
	@Autowired
	private INcPersonnelService ncPersonnelService;
	@Autowired
	private IEaHotelbookspersondService eaHotelbookspersondService;
	@Autowired
	private IEaBusinessApplyService eaBusinessApplyService;
	// 工作流公共执行类
	@Autowired
	private ActivityCommonService activityCommonService;
	@Autowired
	private EaBillServiceImpl eaBillService;
	@Autowired
	private ActZTaskMapper actZTaskMapper;
	@Autowired
	private EaTravelMapper eaTravelMapper;

	/**
	 * 分页列表查询
	 *
	 * @param eaTravel
	 * @param pageNo
	 * @param pageSize
	 * @param req
	 * @return
	 */
	@ApiOperation(value="差旅费报销单-分页列表查询", notes="差旅费报销单-分页列表查询")
	@GetMapping(value = "/list")
	public Result<?> queryPageList(EaTravel eaTravel,
								   @RequestParam(name="billDateBegin", required = false) String billDateBegin,
								   @RequestParam(name="billDateEnd", required = false) String billDateEnd,
								   @RequestParam(name="billCode", required = false) String billCode,
								   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
								   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
								   HttpServletRequest req) {
		QueryWrapper<EaTravel> queryWrapper = QueryGenerator.initQueryWrapper(eaTravel, req.getParameterMap());
		//add-begin-by wujinbiao for 添加查询条件 列表排序，创建人
		if (StringUtils.isNotBlank(billDateBegin)){
			queryWrapper.ge("bill_date", billDateBegin);
		}
		if (StringUtils.isNotBlank(billDateEnd)){
			queryWrapper.le("bill_date", billDateEnd);
		}
		if(StringUtils.isNotBlank(billCode)){
			// 单据编号模糊查询
			queryWrapper.like("bill_no",billCode);
		}
		queryWrapper.orderByDesc("create_time");
		LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
		queryWrapper.and(
				wrapper -> wrapper.eq("create_by",loginUser.getId()).or().eq("person_id",loginUser.getPkPsndoc())
		);

		//add-end-by wujinbiao for 添加查询条件
		Page<EaTravel> page = new Page<EaTravel>(pageNo, pageSize);
		IPage<EaTravel> pageList = eaTravelService.page(page, queryWrapper);
		List<EaTravel> records = pageList.getRecords();
		for (EaTravel eaTravel1: records) {
			NcPersonnel ncPersonnel = ncPersonnelService.queryById(eaTravel1.getPersonId());
			if(ncPersonnel != null){
				eaTravel1.setPersonIdName(ncPersonnel.getName());
			}
		}
		return Result.OK(pageList);
	}
	
	/**
	 *   添加
	 *
	 * @param eaTravelPage
	 * @return
	 */
	@AutoLog(value = "差旅费报销单-添加")
	@ApiOperation(value="差旅费报销单-添加", notes="差旅费报销单-添加")
	@PostMapping(value = "/add")
	public Result<?> add(@RequestBody EaTravelPage eaTravelPage) {
		EaTravel eaTravel = new EaTravel();
		BeanUtils.copyProperties(eaTravelPage, eaTravel);

		// update-begin-Autor: wjb date: 2022-02-09 10:47 for: 生成单据编号
		JSONObject jsonObj = new JSONObject();
		jsonObj.put("prefix","CLBX"); // 编码前缀
		Object result = FillRuleUtil.executeRule("common_code", jsonObj);
		eaTravel.setBillNo(result.toString());
		// update-end-Autor: wjb date: 2022-02-09 10:47 for: 生成单据编号
		eaTravel.setState(0);
		eaTravelService.saveMain(eaTravel, eaTravelPage.getEaBookDetailList(),eaTravelPage.getEaApplyDetailList());
		EaTravelPage resultPage = new EaTravelPage();
		BeanUtils.copyProperties(eaTravel,resultPage);
		resultPage.setEaBookDetailList(eaTravelPage.getEaBookDetailList());
//		resultPage.setEaApplyDetailList(eaTravelPage.getEaApplyDetailList());

		// update-begin-author wjb 2022-02-10 15:49 返回关联的申请单实体
		QueryWrapper<EaBusinessApply> params = new QueryWrapper<>();
		params.eq("ea_travel_id",eaTravel.getId());
		EaBusinessApply eaBusinessApply = eaBusinessApplyService.getOne(params);
		List<EaBusinessApply> eaBusinessApplyList = new ArrayList<>();
		eaBusinessApplyList.add(eaBusinessApply);
		resultPage.setEaApplyDetailList(eaBusinessApplyList);
		// update-end-author wjb 2022-02-10 15:49 返回关联的申请单实体

		//add-end-by 2022-02-07 wjb for 返回主表、子表数据给前端
		return Result.OK(resultPage);
	}
	
	/**
	 *  编辑
	 *
	 * @param eaTravelPage
	 * @return
	 */
	@AutoLog(value = "差旅费报销单-编辑")
	@ApiOperation(value="差旅费报销单-编辑", notes="差旅费报销单-编辑")
	@PostMapping(value = "/edit")
	public Result<?> edit(@RequestBody EaTravelPage eaTravelPage) {
		EaTravel eaTravel = new EaTravel();
		BeanUtils.copyProperties(eaTravelPage, eaTravel);
		EaTravel eaTravelEntity = eaTravelService.getById(eaTravel.getId());
		if(eaTravelEntity==null) {
			return Result.error("未找到对应数据");
		}
		eaTravelService.updateMain(eaTravel, eaTravelPage.getEaBookDetailList(),eaTravelPage.getEaApplyDetailList());
		//add-begin-by 2022-02-07 wjb for 返回主表、子表数据给前端
		EaTravelPage resultPage = new EaTravelPage();
		BeanUtils.copyProperties(eaTravel,resultPage);
		resultPage.setEaBookDetailList(eaTravelPage.getEaBookDetailList());
		// 关联的申请单实体
		QueryWrapper<EaBusinessApply> params = new QueryWrapper<>();
		params.eq("ea_travel_id",eaTravel.getId());
		EaBusinessApply eaBusinessApply = eaBusinessApplyService.getOne(params);
		List<EaBusinessApply> eaBusinessApplyList = new ArrayList<>();
		eaBusinessApplyList.add(eaBusinessApply);
		resultPage.setEaApplyDetailList(eaBusinessApplyList);
		//add-end-by 2022-02-07 wjb for 返回主表、子表数据给前端
		//add-end-by 2022-02-07 wjb for 返回主表、子表数据给前端
		return Result.OK(resultPage);
	}
	
	/**
	 *   通过id删除
	 *
	 * @param id
	 * @return
	 */
	@AutoLog(value = "差旅费报销单-通过id删除")
	@ApiOperation(value="差旅费报销单-通过id删除", notes="差旅费报销单-通过id删除")
	@DeleteMapping(value = "/delete")
	public Result<?> delete(@RequestParam(name="id",required=true) String id) {
		QueryWrapper<EaTravel> params = new QueryWrapper<>();
		params.eq("id",id);
		EaTravel eaTravel = eaTravelService.getOne(params);
		if(eaTravel != null && eaTravel.getState() > 0){
			return Result.error("该单据已发起流程,不可删除!");
		}
		eaTravelService.delMain(id);
		return Result.OK("删除成功!");
	}
	
	/**
	 *  批量删除
	 *
	 * @param ids
	 * @return
	 */
	@AutoLog(value = "差旅费报销单-批量删除")
	@ApiOperation(value="差旅费报销单-批量删除", notes="差旅费报销单-批量删除")
	@DeleteMapping(value = "/deleteBatch")
	public Result<?> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
		this.eaTravelService.delBatchMain(Arrays.asList(ids.split(",")));
		return Result.OK("批量删除成功！");
	}
	
	/**
	 * 通过id查询
	 *
	 * @param id
	 * @return
	 */
	@ApiOperation(value="差旅费报销单-通过id查询", notes="差旅费报销单-通过id查询")
	@GetMapping(value = "/queryById")
	public Result<?> queryById(@RequestParam(name="id",required=true) String id) {
		EaTravelPage eaTravelPage = new EaTravelPage();
		EaTravel eaTravel = eaTravelService.getById(id);
		if(eaTravel==null) {
			return Result.error("未找到对应数据");
		}
		String personIdName = "";
		// update-begin-by wjb 详情返回报销人中文、还款人中文 申请单详情 发票详情
		//查询报销人中文
		if (StringUtils.isNotBlank(eaTravel.getPersonId())){
			NcPersonnel ncPersonnel = ncPersonnelService.queryById(eaTravel.getPersonId());
			if(ncPersonnel != null){
				personIdName = ncPersonnel.getName();
				eaTravel.setPersonIdName(personIdName);
			}
		}
		//如果报销人和收款人是同一个人，直接返回报销人中文给收款人
//		if(StringUtils.isNotBlank(eaTravel.getRecPersonId()) && eaTravel.getRecPersonId().equals(eaTravel.getPersonId())){
//			eaTravel.setRecPersonIdName(personIdName);
//		}else {
//			NcPersonnel ncPersonnel = ncPersonnelService.queryById(eaTravel.getRecPersonId());
//			eaTravel.setRecPersonIdName(ncPersonnel.getName());
//		}
		BeanUtils.copyProperties(eaTravel,eaTravelPage);
		List<EaBookDetail> eaBookDetails = eaBookDetailService.selectByMainId(eaTravel.getId());
		// 获取关联的申请单实体
		QueryWrapper<EaBusinessApply> params = new QueryWrapper<>();
		params.eq("ea_travel_id",id);
		EaBusinessApply eaBusinessApply = eaBusinessApplyService.getOne(params);
		List<EaBusinessApply> eaBusinessApplyList  = new ArrayList<>();
		eaBusinessApplyList.add(eaBusinessApply);

		eaTravelPage.setEaApplyDetailList(eaBusinessApplyList);
		eaTravelPage.setEaBookDetailList(eaBookDetails);
		//update-end-by wjb 详情返回报销人中文 申请单详情 发票详情
		return Result.OK(eaTravelPage);
	}

	 /**
	 * @Description 差旅费报销单打印模板
	 * @author  wujinbiao
	 * @date 2022/2/9 09:32
	 * @param id
	 * @return org.jeecg.common.api.vo.Result<?>
	 */
	 @ApiOperation(value="差旅费报销单打印模板-通过id查询", notes="差旅费报销单打印模板-通过id查询")
	 @GetMapping(value = "/selectById")
	 public Result<?> selectById(@RequestParam(name="id",required=true) String id) {
		 EaTravel eaTravel = eaTravelService.getById(id);
		 if(eaTravel==null) {
			 return Result.error("未找到对应数据");
		 }
		 EaTravelPrintVo eaTravelPrintVo = new EaTravelPrintVo();
		 BeanUtils.copyProperties(eaTravel,eaTravelPrintVo);

		 //查询报销人中文
		 if (StringUtils.isNotBlank(eaTravel.getPersonId())){
			 NcPersonnel ncPersonnel = ncPersonnelService.queryById(eaTravel.getPersonId());
			 if(ncPersonnel != null){
				 eaTravelPrintVo.setPersonIdName(ncPersonnel.getName());
			 }
		 }
		 //开始时间 结束时间
		 QueryWrapper<EaBusinessApply> params = new QueryWrapper<>();
		 params.eq("ea_travel_id",id);
		 EaBusinessApply eaBusinessApply = eaBusinessApplyService.getOne(params);
		 if (eaBusinessApply != null){
		 	eaTravelPrintVo.setStartDate(eaBusinessApply.getStartDate());
		 	eaTravelPrintVo.setEndDate(eaBusinessApply.getEndDate());
		 }

		 // 实际付款金额转为大写金额
		 BigDecimal actualPayAmt = eaTravel.getActualPayAmt() != null ? eaTravel.getActualPayAmt() : new BigDecimal(0);
		 String actualPayAmt_cn = ConvertUpMoneyUtil.toChinese(String.valueOf(actualPayAmt));
		 eaTravelPrintVo.setActualPayAmt_cn(actualPayAmt_cn);

		 // 费用明细
		 List<EaBookDetail> eaBookDetailList = eaBookDetailService.selectByMainId(id);
		 eaTravelPrintVo.setEaBookDetailList(eaBookDetailList);

		 // 入住人集合
		 List<EaCheckInPersonVo> rzrList = new ArrayList<>();
		 List<String> fpids = new ArrayList<>();
		 // 获取入住人明细
		 if(eaBookDetailList != null && eaBookDetailList.size()>0){
			 for (EaBookDetail eaBookDetail:eaBookDetailList) {
			 	// 发票类型为住宿 kind = 3
			 	if ("3".equals(eaBookDetail.getKind())){
					String fpid = eaBookDetail.getFpid();
					// 判断当前发票录入人是否已经记录 ，没有则记录
					if(!fpids.contains(fpid)){
						fpids.add(fpid);
						List<EaCheckInPersonVo> rzr = eaHotelbookspersondService.getByFpid(fpid);
						rzrList.addAll(rzr);
					}
				}
			 }
		 }
		 eaTravelPrintVo.setEaCheckInPersonVoList(rzrList);

		 //审批流程
		 // update-begin-Autor: wjb date: 2022-02-10 14:50 for: 添加流程审批记录
		 if (StringUtils.isNotBlank(eaTravel.getProcInstId())){
			 List<Map<String, Object>> nodeList = activityCommonService.getNodeList(eaTravel.getProcInstId());
			 eaTravelPrintVo.setSpjl(nodeList);
		 }
		 // update-end-Autor: wjb date: 2022-02-10 14:50 for: 添加流程审批记录
		 return Result.OK(eaTravelPrintVo);
	 }



	/**
	 * 通过id查询
	 *
	 * @param id
	 * @return
	 */
	@ApiOperation(value="费用明细--通过主表ID查询", notes="费用明细-通过主表ID查询")
	@GetMapping(value = "/queryEaBookDetailByMainId")
	public Result<?> queryEaBookDetailListByMainId(@RequestParam(name="id",required=true) String id) {
		List<EaBookDetail> eaBookDetailList = eaBookDetailService.selectByMainId(id);
		return Result.OK(eaBookDetailList);
	}
	/**
	 * 通过id查询
	 *
	 * @param id
	 * @return
	 */
	@ApiOperation(value="申请单明细-通过主表ID查询", notes="申请单明细-通过主表ID查询")
	@GetMapping(value = "/queryEaApplyDetailByMainId")
	public Result<?> queryEaApplyDetailListByMainId(@RequestParam(name="id",required=true) String id) {
		List<EaApplyDetail> eaApplyDetailList = eaApplyDetailService.selectByMainId(id);
		return Result.OK(eaApplyDetailList);
	}

    /**
    * 导出excel
    *
    * @param request
    * @param eaTravel
    */
    @RequestMapping(value = "/exportXls")
    public ModelAndView exportXls(HttpServletRequest request, EaTravel eaTravel) {
      // Step.1 组装查询条件查询数据
      QueryWrapper<EaTravel> queryWrapper = QueryGenerator.initQueryWrapper(eaTravel, request.getParameterMap());
      LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();

      //Step.2 获取导出数据
      List<EaTravel> queryList = eaTravelService.list(queryWrapper);
      // 过滤选中数据
      String selections = request.getParameter("selections");
      List<EaTravel> eaTravelList = new ArrayList<EaTravel>();
      if(oConvertUtils.isEmpty(selections)) {
          eaTravelList = queryList;
      }else {
          List<String> selectionList = Arrays.asList(selections.split(","));
          eaTravelList = queryList.stream().filter(item -> selectionList.contains(item.getId())).collect(Collectors.toList());
      }

      // Step.3 组装pageList
      List<EaTravelPage> pageList = new ArrayList<EaTravelPage>();
      for (EaTravel main : eaTravelList) {
          EaTravelPage vo = new EaTravelPage();
          BeanUtils.copyProperties(main, vo);
          List<EaBookDetail> eaBookDetailList = eaBookDetailService.selectByMainId(main.getId());
          vo.setEaBookDetailList(eaBookDetailList);
          List<EaApplyDetail> eaApplyDetailList = eaApplyDetailService.selectByMainId(main.getId());
//          vo.setEaApplyDetailList(eaApplyDetailList);
          pageList.add(vo);
      }

      // Step.4 AutoPoi 导出Excel
      ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
      mv.addObject(NormalExcelConstants.FILE_NAME, "ea_travel列表");
      mv.addObject(NormalExcelConstants.CLASS, EaTravelPage.class);
      mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("ea_travel数据", "导出人:"+sysUser.getRealname(), "ea_travel"));
      mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
      return mv;
    }

    /**
    * 通过excel导入数据
    *
    * @param request
    * @param response
    * @return
    */
    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
      MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
      Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
      for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
          MultipartFile file = entity.getValue();// 获取上传文件对象
          ImportParams params = new ImportParams();
          params.setTitleRows(2);
          params.setHeadRows(1);
          params.setNeedSave(true);
          try {
              List<EaTravelPage> list = ExcelImportUtil.importExcel(file.getInputStream(), EaTravelPage.class, params);
              for (EaTravelPage page : list) {
                  EaTravel po = new EaTravel();
                  BeanUtils.copyProperties(page, po);
                  eaTravelService.saveMain(po, page.getEaBookDetailList(),page.getEaApplyDetailList());
              }
              return Result.OK("文件导入成功！数据行数:" + list.size());
          } catch (Exception e) {
              log.error(e.getMessage(),e);
              return Result.error("文件导入失败:"+e.getMessage());
          } finally {
              try {
                  file.getInputStream().close();
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
      }
      return Result.OK("文件导入失败！");
    }

	 /**
	  * 发票更新
	  *
	  * @param billIds
	  * @return
	  */
	 @AutoLog(value = "发票更新")
	 @ApiOperation(value = "发票更新", notes = "发票更新")
	 @PutMapping(value = "/updeteFpState")
	 @Transactional
	 public Result<?> updeteFpState(@RequestParam(name = "billIds", required = true) String billIds) {
		 if (!org.apache.commons.lang.StringUtils.isEmpty(billIds)) {
			 String[] ids = billIds.split(",");
			 // 发票金额
			 double amount = 0;
			 // 实际付款金额
			 double actualEaAmt = 0;
			 // 业务表id
			 String billId = "";
			 List<EaBookDetail> eaBookDetails = new ArrayList<>();
			 List<EaBill> eaBills = new ArrayList<>();
			 for (String id : ids) {
				 // 需要更新的发票明细行数据
				 EaBookDetail eaBookDetail = eaBookDetailService.selectById(id);
				 if(eaBookDetail == null || "".equals(eaBookDetail)){
					 return Result.error("找不到对应数据");
				 }
				 // 需要更新的发票数据
				 EaBill eaBill = eaBillService.getById(eaBookDetail.getFpid());
				 billId = eaBookDetail.getBillId();
				 // 发票被引用
				 if ("1".equals(eaBill.getIsused()) && eaBookDetail.getBillId() != null) {
					 amount = PreciseCompute.add(amount,eaBookDetail.getAmount().doubleValue());
					 actualEaAmt = PreciseCompute.add(actualEaAmt,eaBookDetail.getActualEaAmt().doubleValue());
					 // 关联的表单id置为空
					 eaBookDetail.setBillId("");
					 // 发票状态更新
					 eaBill.setIsused("0");

					 eaBookDetails.add(eaBookDetail);
					 eaBills.add(eaBill);
				 }
			 }
			 // 取消费用明细行和业务表单的关系
			 eaBookDetailService.updateBatchById(eaBookDetails);
			 // 修改发票已报销状态
			 eaBillService.updateBatchById(eaBills);

			 // 报销单减去实际付款金额、报销金额
			 if (billId != ""){
				 EaTravel eaTravel = eaTravelMapper.selectById(billId);
				 // 修改待办列表的还款金额
				 Map<String, Object> params = new HashMap<>();
				 params.put("table_id",billId);
				 List<ActZTask> actZTasks = actZTaskMapper.selectByMap(params);
				 if(actZTasks.size() > 0){
					 // 修改任务列表 对应的借款金额
					 ActZTask actZTask = actZTasks.get(0);
					 actZTask.setTotalFee(new BigDecimal(PreciseCompute.sub(eaTravel.getEaAmt().doubleValue(),amount)));
					 actZTaskMapper.updateById(actZTask);
				 }
				 // 报销金额 修改
				 eaTravel.setEaAmt(new BigDecimal(PreciseCompute.sub(eaTravel.getEaAmt().doubleValue(),amount)));
				 // 实际付款金额 修改
				 eaTravel.setActualPayAmt(new BigDecimal(PreciseCompute.sub(eaTravel.getActualPayAmt().doubleValue(),actualEaAmt)));
				 eaTravelService.updateById(eaTravel);
			 }
		 }
		 return Result.OK();
	 }

}
